$(function(){
	$("#publishBtn").click(publish);
});

function publish() {
	$("#publishModal").modal("hide");

	//获取标题和内容
	var title = $("#recipient-name").val();
	var context = $("#message-text").val();
	$.post(
		CONTEXT_PATH+"/discuss/add",
		{
			"title":title,"context":context,
			function(data){
				data = $.parseJSON(data);

				$("#hintBody").text(data.msg);

				//显示提示框
				$("#hintModal").modal("show");
				setTimeout(function(){
					$("#hintModal").modal("hide");
					if(data.code == 0){
						window.location.reload();
					}
				}, 2000);
			}
		}
	)

	$("#hintModal").modal("show");
	setTimeout(function(){
		$("#hintModal").modal("hide");
	}, 2000);
}